/* * Copyright (C) 2021 Huawei Device Co., Ltd.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.zhouyou.http.demo.view;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.aafwk.ability.delegation.IAbilityDelegator;
import ohos.app.Context;
import org.junit.Test;

import static org.junit.Assert.*;

public class HorizontalProgressDialogTest {
    private static IAbilityDelegator sAbilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
    @Test
    public void setMessage() {
        Context context= sAbilityDelegator.getAppContext();
        HorizontalProgressDialog   dialog = new HorizontalProgressDialog(context);
        dialog.setMessage("下载完成");
        String message =dialog.getMessgeView().getText();
        assertTrue("message  is not equals", message.equals("下载完成"));


    }

    @Test
    public void setTitle() {
        Context context= sAbilityDelegator.getAppContext();
        HorizontalProgressDialog   dialog = new HorizontalProgressDialog(context);
        dialog.setTitle("下载文件");
        String message =dialog.getTitleView().getText();
        assertTrue("title is not equals  ", message.equals("下载文件"));


    }

    @Test
    public void setProgress() {
        Context context= sAbilityDelegator.getAppContext();
        HorizontalProgressDialog   dialog = new HorizontalProgressDialog(context);
        dialog.setProgress(100);
        int  progress =dialog.getProgress().getProgress();
        assertTrue("progress is not 100  ", progress==100);

    }


    private void sleep(long time) {
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}